package generator.structure;

import java.io.Serializable;



public final class Pair<X,Y> implements Comparable<Pair<X,Y>>, Serializable {
	
	public X first_;
	public Y second_;
	
	public Pair() {
		
	}
	
	public Pair(X first, Y second) {
		first_ = first; second_ = second;		
	}
	
	public X getFirst() {
		return first_;
	}
	
	public Y getSecond() {
		return second_;
	}
	
	public void setFirst(X first) {
		first_ = first;
	}
	
	public void setSecond(Y second) {
		second_ = second;
	}
	
	public String toString() {
		return "<" + first_ + " , " + second_ + ">";
	}
	
	@SuppressWarnings("unchecked")
	public int compareTo(Pair<X,Y> z) {		
		int rst = ((Comparable<X>)first_).compareTo(z.first_);
		if (rst!=0) return rst;
		else return ((Comparable<Y>)second_).compareTo(z.second_);
	}
	
	@SuppressWarnings("unchecked")
	public boolean equals(Object o) {
		return compareTo((Pair<X,Y>) o) == 0;
	}
	
	public int hashCode(){
		return toString().hashCode();
	}
}
